package selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

public class hometask1 {

    @Test
    public static void pagesTranfers() {

        // Create a new instance of the Firefox driver
        WebDriver driver = new FirefoxDriver();

        // visit first site
        driver.get("http://www.ukr.net/");
        driver.findElement(By.xpath("//*[@id=\"hot-notlogged\"]/div[1]/a[1]")).click();
        System.out.println("1. Open www.ukr.net and click element successfully");

        // switch focus of WebDriver to the next found window handle (that's your newly opened window)
        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle);
        }
        // visit second site
        driver.findElement(By.id("bigmirTop")).findElement(By.tagName("a")).click();
        System.out.println("2. Open www.ua.sinoptik.ua and click element successfully");

        // switch focus of WebDriver to the next found window handle (that's your newly opened window)

        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle);
        }
        // visit third site
        WebElement logo = driver.findElement(By.className("b-logo"));

        Assert.assertEquals(true, logo.isDisplayed());
        System.out.println("3. Open www.bigmir.net and locate element successfully");

        driver.quit();
        System.out.println("4. Close browser");

    }



}
